package com.limao.DBProvider;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;

import com.limao.DBDataClass.SysProjectCateDataClass;
import com.limao.DbConnection.DbConnectionManager;

public class CrowdSysCateProvider {
	
	private static class DB_sys_cate_ProviderContainer {
		private static CrowdSysCateProvider instance = new CrowdSysCateProvider();
	}

	public static CrowdSysCateProvider getInstance() {
		return DB_sys_cate_ProviderContainer.instance;
	}


	// 初始化
	private CrowdSysCateProvider() {

	}


	//&新鲜宝   众筹项目分类
	public ArrayList<SysProjectCateDataClass> loadProjectcateAll() {
		
		ArrayList<SysProjectCateDataClass> list = new ArrayList<SysProjectCateDataClass>();
		
		SysProjectCateDataClass tmp = null;
		Connection con = null;
		PreparedStatement pstmt = null;
		ResultSet rs = null;
		try {
			con = DbConnectionManager.getConnection();
			pstmt = con.prepareStatement("select * from cd_sys_projectcate where catestate=1 order by catesort asc");
			rs = pstmt.executeQuery();
			while (rs.next()) {
				tmp = new SysProjectCateDataClass();
				
				tmp.cateid = rs.getString("cateid");
				tmp.catename = rs.getString("catename");
				tmp.cateimage = rs.getString("cateimage");
				tmp.catestate = rs.getString("catestate");
				tmp.catesort = rs.getString("catesort");

				list.add(tmp);
			}

		} catch (Exception e) {
			list.clear();
			e.printStackTrace();
		} finally {
			DbConnectionManager.closeConnection(rs, pstmt, con);
		}
		
		return list;
		
	}


	
	
	
	

}
